<template>
    <div>
        <el-form :model="formData" ref="form" label-width="80px" :inline="false" >
            <el-form-item label="*属性名：">
                <el-input v-model="formData.attributeName" placeholder="请输入属性名"></el-input>
            </el-form-item>
            <el-form-item label="*属性值：">
                <el-input type="textarea" v-model="formData.attributeValue"  placeholder="请输入属性值（用竖线隔开，比如：红色|橙色|黄色|绿色）"></el-input>
            </el-form-item>
            <div style="display: flex; justify-content: flex-end; margin-top: 10px; margin-bottom: 50px;">
            <el-form-item>
               
                <el-button type="primary" @click="close">关闭</el-button>
                <el-button type="primary" @click="onSubmit">确定</el-button>
            </el-form-item>
            </div>
        </el-form>
    </div>
</template>

<script setup>
import {ref,defineEmits,defineProps} from 'vue'
import reqeust from '@/api/request'
import router from '@/router'
let emits = defineEmits(['close'])
let props = defineProps(['data'])
let formData = ref({ ...props.data })
let close = ()=>{
    emits('close')
}

let onSubmit =()=>{
    reqeust.post("/commodity/material_attribute/update", formData.value,{
        headers:{
            'Content-Type':'application/json',
        },
        body: JSON.stringify(formData.value)
    }).then(resp=>{
        console.log(resp)
        if(resp.code == 200){
            router.push("/commodity/material_attribute")
            emits('close')
           
        }
    })
}

</script>

<style lang='scss' scoped>

</style>
